package com.ncepu.jjoj.config;

import com.ncepu.jjoj.constant.RabbitMQConstant;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author simon_jiang
 * @version 1.0
 */
@Configuration
public class RabbitMQConfig {

    @Bean
    public DirectExchange directExchange() {
        return new DirectExchange(RabbitMQConstant.DIRECT_EXCHANGE, true, false);
    }

    @Bean
    public Queue myQueue() {
        return new Queue(RabbitMQConstant.QUEUE, true, false, false);
    }

    @Bean
    public Binding binding() {
        return BindingBuilder.bind(myQueue()).to(directExchange()).with(RabbitMQConstant.ROUTING_KEY);
    }
}
